<?php
	$galeries = array();
	$placeholdersNamespaces = array();
?>
<?php foreach ((array)$this->data as $row):?>
<?php
	// kolekcjonowanie tytolow galerii
	if (!isset($galeries[$row['gallery_name']])) {
		$galeries[$row['gallery_name']] = $row;
	}
	// przestrzeń nazw
	$placeholderNamespace = 'gallery-' . $row['gallery_name'];

	$this->placeholder($placeholderNamespace)->captureStart();
?>
	<li class="image img">
		<span></span>	
		<a href="<?php print $this->url(array('module' => 'gallery','controller' => 'album','action' => 'display','id' => $row['album_id']),'default',true);?>">
			<ins></ins>
			<img alt="<?php print $row['name']?>" src="/upload/gallery/polaroid/<?php print $this->escape($row['image'])?>"></a>

		<?php if ('' != $row['album_name']):?>
		<em><?php print $row['album_name']?> (<?php print $row['albums']?>)</em>
		<?php endif;?>
  	</li>
<?php $this->placeholder($placeholderNamespace)->captureEnd();?>
<?php endforeach;?>

<ul id="gallery-preview">
	<?php foreach ($galeries as $gallery):?>
	<li class="gallery">
		<h3 class="name"><?php print $gallery['gallery_name']?></h3>
		<div class="description"><?php print $gallery['gallery_description']?></div>
		<ul class="album photo style2">
			<?php print $this->placeholder('gallery-' . $gallery['gallery_name'])?>
		</ul>
	</li>
	<?php endforeach;?>
</ul>